if '__main__' == __name__:
    import argparse
    from PyCmpltrtok.common import sep

    def _main():

        # specify or override params from CLI
        parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
        # group #1
        parser.add_argument('--name', help='The name of this training, VERY important to TVTS.', type=str, default='tvts_ex_vgg16_torch_cifar10_DDP')
        parser.add_argument('--memo', help='The memo.', type=str, default='(no memo)')
        parser.add_argument('--temp', help='Run as temporary code', action='store_true')
        parser.add_argument('-t', '--test', help='Only run testing phase, no training.', action='store_true')
        # group #2
        parser.add_argument('-n', '--epochs', help='How many epoches to train.', type=int, default=2)
        parser.add_argument('--batch', help='Batch size.', type=int, default=256)
        parser.add_argument('--lr', help='Learning rate.', type=float, default=None)
        parser.add_argument('--gamma', help='Multiplicative factor of learning rate decay per epoch.', type=float, default=None)
        # group #3
        parser.add_argument('--pi', help='id of the parent training', type=int, default=0)
        parser.add_argument('--pe', help='parent epoch of the parent training', type=int, default=0)
        parser.add_argument('--save_freq', help='How many epochs save weights once.', type=int, default=1)
        parser.add_argument('--save_dir', help='The dir where weights saved.', type=str, default='SAVE_DIR')
        # group #4
        parser.add_argument('--init_weights', help='The path to the stored weights to init the model.', type=str, default=None)
        parser.add_argument('--host', help='Host of the mongodb for tvts.', type=str, default='tvts.DEFAULT_HOST')
        parser.add_argument('--port', help='Port of the mongodb for tvts.', type=str, default='tvts.DEFAULT_PORT')
        # parse CLI args
        args = parser.parse_args()
        sep()
        print(dir(args))
        sep()
        # xdict = dict(args)  # TypeError: 'Namespace' object is not iterable
        # https://stackoverflow.com/questions/19907442/explain-dict-attribute
        print(args.__dict__)
        sep('sorted')
        keys = sorted(args.__dict__.keys())
        xdict = {}
        for k in keys:
            xdict[k] = args.__dict__[k]
        print(xdict)
        sep('All over')
        
    _main()
    